package com.example.lenovo.demo0426am;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private WebView wvview;
    private Button btGz;
    private  Button btSh;
    private Button btHn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        openUrl();
        btGz=findViewById(R.id.bt_gz);
        btGz.setOnClickListener(this);
        btHn=findViewById(R.id.bt_hn);
        btHn.setOnClickListener(this);
        btSh=findViewById(R.id.bt_sh);
        btSh.setOnClickListener(this);
        wvview = findViewById(R.id.wv_view);
        wvview.getSettings().setJavaScriptEnabled(true);

        wvview.setWebChromeClient(new WebChromeClient() );
        wvview.setWebViewClient(new WebViewClient());
        wvview.loadUrl("http://m.weather.com.cn/mweather/101010100.shtml");
    }

    private void openUrl() {
        wvview.loadUrl("http://m.weather.com.cn/mweather/"+".shtml");
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bt_gz:
                openUrl("1010101200");
                break;
            case R.id.bt_sh:
                openUrl("101010100");
                break;
            case R.id.bt_hn:
                openUrl("101010100");
                break;

        }
    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }
}